package com.ruoyi.production.service.impl.regulator;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.OrderAllocation;
import com.ruoyi.order.mapper.OrderAllocationMapper;
import com.ruoyi.production.domain.regulator.RegulatorApply;
import com.ruoyi.production.mapper.regulator.RegulatorApplyMapper;
import com.ruoyi.production.service.regulator.IRegulatorApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 调节剂申请Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@Service
public class RegulatorApplyServiceImpl implements IRegulatorApplyService
{
    @Autowired
    private RegulatorApplyMapper regulatorApplyMapper;
    @Autowired
    private OrderAllocationMapper orderAllocationMapper;

    /**
     * 查询调节剂申请
     *
     * @param regulatorApplyId 调节剂申请ID
     * @return 调节剂申请
     */
    @Override
    public RegulatorApply selectRegulatorApplyById(Long regulatorApplyId)
    {
        return regulatorApplyMapper.selectRegulatorApplyById(regulatorApplyId);
    }

    /**
     * 查询调节剂申请列表
     *
     * @param regulatorApply 调节剂申请
     * @return 调节剂申请
     */
    @Override
    public List<RegulatorApply> selectRegulatorApplyList(RegulatorApply regulatorApply)
    {
        return regulatorApplyMapper.selectRegulatorApplyList(regulatorApply);
    }

    /**
     * 新增调节剂申请
     *
     * @param regulatorApply 调节剂申请
     * @return 结果
     */
    @Override
    public int insertRegulatorApply(RegulatorApply regulatorApply)
    {
        Long orderAllocationId = regulatorApply.getOrderAllocationId();
        OrderAllocation orderAllocation = orderAllocationMapper.selectOrderAllocationById(orderAllocationId);
        regulatorApply.setOrderId(orderAllocation.getOrderId());














        regulatorApply.setCreateTime(DateUtils.getNowDate());



        return regulatorApplyMapper.insertRegulatorApply(regulatorApply);
    }

    /**
     * 修改调节剂申请
     *
     * @param regulatorApply 调节剂申请
     * @return 结果
     */
    @Override
    public int updateRegulatorApply(RegulatorApply regulatorApply)
    {
        regulatorApply.setUpdateTime(DateUtils.getNowDate());
        return regulatorApplyMapper.updateRegulatorApply(regulatorApply);
    }

    /**
     * 批量删除调节剂申请
     *
     * @param regulatorApplyIds 需要删除的调节剂申请ID
     * @return 结果
     */
    @Override
    public int deleteRegulatorApplyByIds(Long[] regulatorApplyIds)
    {
        return regulatorApplyMapper.deleteRegulatorApplyByIds(regulatorApplyIds);
    }

    /**
     * 删除调节剂申请信息
     *
     * @param regulatorApplyId 调节剂申请ID
     * @return 结果
     */
    @Override
    public int deleteRegulatorApplyById(Long regulatorApplyId)
    {
        return regulatorApplyMapper.deleteRegulatorApplyById(regulatorApplyId);
    }
}
